﻿{% extends "admin/base.html" %}
{% load i18n %}

{% block header %}

{% endblock %}

{% block content %}
<div class="wrap">
 	<h2 class="title1">{% trans "Edit comments" %}</h2>
 	<form id="posts-filter" action="{% url admin_delete_comments user.username %}" method="post">
 		<input type="hidden" name="next" value="{{ request.path }}">
 		<ul class="horizontal">
 			<li>
 				<a href="{{ blog.get_admin_comments_url }}">
 				{% trans "All comments" %}<span class="count">({{ comment_count }})</span>
 				</a>|&nbsp;
 			</li>
 			<li>
 				<a href="{% url admin_comments_span user.username %}">
 				{% trans "Spam comments" %}<span class="count">({{ spam_count }})</span>
 				</a>
 			</li>
 		</ul>
 		<div class="clear"></div>
 		<div style="margin-top: 10px;">
			<input type="submit" class="button" id="doaction" name="delete" value="{% trans 'Delete' %}">
 		</div>
 		<table class="list">
			<thead>
				<th class="check-column">
				    <input type="checkbox" onclick="$('input[name=checks]').attr('checked',this.checked);">
				</th>
				<th>{% trans "Name" %}</th>
				<th>{% trans "Comment" %}</th>
				<th>{% trans "Article" %}</th>
				</thead>
			<tfoot>
				<th class="check-column">
					<input type="checkbox" onclick="$('input[name=checks]').attr('checked',this.checked);">
				</th>
				<th>{% trans "Name" %}</th>
				<th>{% trans "Comment" %}</th>
				<th>{% trans "Article" %}</th>
			</tfoot>
			<tbody>
				{% if comments %}
				{% for comment in comments %}
				<tr valign="middle" id="comment-{{ comment.id }}" class="list_item">
					<th class="check-column">
						<input type="checkbox" name="checks" value="{{ comment.id }}">
					</th>
					<td> 
		             	<strong>
		             		<img width="40" height="40"
		             			src="{% if comment.user.get_profile.image_url %}/site_media/{{ comment.user.get_profile.image_url }}{% else %}/senbzblog/static/images/default_user_picture.png{% endif %}"
		             			style="float:left; margin-top:3px; margin-right:10px;border:1px solid lightgray;"/>
		             		{% if comment.user_url %}
		             		<a href="{{ comment.user_url }}" target="_blank">{{ comment.user_name }}</a>
		             		{% else %}
		             		{{ comment.user_name }}
		             		{% endif %}
		             	</strong>
		             	<br/>
		             	<a href="mailto:{{ comment.user_email }}">{{ comment.user_email }}</a>
		             	<br/>
		             	{%if comment.ip_address%}
		             	{{comment.ip_address}}
		             	{%endif%}
		             </td>
		             <td>
		             	<div>
		             		{% trans "Posted on" %} {{ comment.submit_date|date:"Y-m-d" }} @ {{ comment.submit_date|date:"H:i" }}
		             	</div>
		             <p>{{ comment.comment|safe|linebreaksbr }}</p>
		             <div class="row-actions">
		             	{% if comment.is_public %}
		             	<span><a title="Sign this comment to spam" 
		             		href="{% url admin_comment_to_spam user.username,comment.id %}?approve=0&next={{ request.path }}">
		             			{% trans "Spam comments" %}</a></span>
		             	{%else%}
		             	<span><a title="Approve this comment" 
		             		href="{% url admin_comment_to_spam user.username,comment.id %}?approve=1&next={{ request.path }}">
		             			{% trans "Approve comments" %}</a></span>
		             	{%endif%}
		             	<span>| 
		             		<a href="javascript:senbz.delete_confirm('{% url admin_delete_comment user.username, comment.id %}?next={{ request.path }}')" class="delete">
		             				{% trans 'Delete' %}</a></span>
		             	<span>|<a href="{% url admin_edit_comment user.username, comment.id %}"> {% trans "Edit" %}</a></span>
		             </div>
		             </td>
		             <td>
		             	<a href="{{ comment.content_object.get_absolute_url }}" target="_blank">
		             		{{ comment.content_object.title }}</a></td>
				</tr>
				{%endfor%}
				{%else%}
				<tr valign="middle">
					<td colspan="4" align="center" style="font-size: 15px;">{% trans "No comments" %}</td>
				</tr>	
				{%endif%}
			</tbody>
		</table>
 	</form>
</div>
{%endblock%}